//
// Created by QT on 2023/11/16.
//

#ifndef FOC_PID_H
#define FOC_PID_H


#include <stdint.h>


typedef struct pid_ctrl
{
    float kp;
    float ki;
    float kd;

    float error, lastError, errorSum, errorSumMax;
    float target, value;

    float lowLimit, upLimit;
    float result;

} pid_ctrl_t;


int pid_ctrl_init(pid_ctrl_t* pid, float p, float i, float d, float lowLimit, float upLimit);

float pid_ctrl_current_calc(pid_ctrl_t* pid, float tarIdq, float fdkIdq, float* udq);



#endif //FOC_PID_H
